#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
int main() {
    int t;
    scanf("%d", &t);
    int l, r, k;
    int sum;
    for (int i = 1; i <= t; i++) {
        scanf("%d%d%d", &l, &r, &k);
        sum = 0;
        if (k == 0)
            printf("%d\n", (r - l + 1) % 2);
        else {
            sum = (r + l) * (r - l + 1) / 2;
            if (sum % 2 == 0)
                printf("0\n");
            else
                printf("1\n");
        }
    }
    return 0;
}